// 工作台
import request from '@/utils/request';
import {object2Url} from "@/utils/trans";

export async function csApi22(data) {
  const res = await request.post('/business/matrixsphpublish/sphQrCode', data);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}
// 总平台 图表数据获取
export async function getDaiLiDate(getDays) {
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    ts,
    ua,
    getDays:getDays
  };
  let url = `/business/oemAgent/getCreateDate${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 代理端 图表数据获取
export async function getAgentDate(getDays,oemId) {
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    ts,
    ua,
    getDays:getDays,
    oemId:oemId
  };
  let url = `/business/oemAgent/getAgentDate${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 代理端 图表数据获取
export async function getMerchantCount(getDays,username,types) {
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    ts,
    ua,
    getDays:getDays,
    username:username,
    types:types
  };
  let url = `/business/oemAgent/getMerchantCount${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
